<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <ui:composition template="../TemplateAdmin.xhtml">
        <ui:define name="title">
            <h:outputText value="Complaint Management"></h:outputText>
        </ui:define>       
        <ui:define name="body">     
            <h:form id="form" style="width: 100%">
                <p:growl id="messages" showDetail="true"/> 
                <p:dataTable id="dataTable" var="item" value="#{complaintController.items}"
                             paginator="true" rows="10" paginatorPosition="bottom" resizableColumns="true"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             rowsPerPageTemplate="5,10,15" style="width: 100%" widgetVar="roomTable"
                             editable="true">
                    <f:facet name="header">
                        <h:outputText value="List of Complaint"/>
                        <p:outputPanel style="float: right">
                            <h:outputText value="Search by all fileds"/>
                            <h:inputText id="globalFilter" onkeyup="roomTable.filter();"/>
                        </p:outputPanel>
                    </f:facet>

                    <p:ajax event="rowEdit" listener="#{complaintController.onEdit}" />
                    <p:ajax event="rowEditCancel" listener="#{complaintController.onEditCancel}" />

                    <p:column headerText="ID" sortBy="#{item.cpID}" >
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.cpID}" style="width: 100%"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:outputText value="#{item.cpID}" style="width: 100%"/>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>
                    <p:column headerText="Order" sortBy="#{item.odID}" filterMatchMode="exact" filterBy="#{item.odID}">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.odID}" style="width: 100%"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:outputText value="#{item.odID}" style="width: 100%"/>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>
                    <p:column headerText="User" sortBy="#{item.usID.usName}" filterMatchMode="exact" filterBy="#{item.usID.usName}">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usID.usName}" style="width: 100%"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:outputText value="#{item.usID.usName}" style="width: 100%"/>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>               


                    <p:column headerText="Description" sortBy="#{item.cpDescription}">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.cpDescription}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:outputText value="#{item.cpDescription}" style="width: 100%"/>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>

                    <p:column headerText="Manager" sortBy="#{item.mnID.mnName}" filterMatchMode="exact" filterBy="#{item.mnID.mnName}">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.mnID.mnName}" style="width: 100%"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:inputText value="#{item.mnID.mnName}" style="width: 100%"/>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>      
                    <p:column sortBy="#{item.cpCreated}" headerText="Created Date"
                              filterBy="#{item.cpCreated}" filterMatchMode="exact">
                        <p:cellEditor>
                            <f:facet name="output">         
                                <h:outputText value="#{item.cpCreated}">
                                    <f:convertDateTime pattern="MM/dd/yyyy" />
                                </h:outputText>
                            </f:facet>
                            <f:facet name="input">                            
                                <h:outputText value="#{item.cpCreated}">
                                    <f:convertDateTime pattern="MM/dd/yyyy" />
                                </h:outputText>
                            </f:facet>
                        </p:cellEditor>
                    </p:column>

                    <p:column sortBy="#{item.cpAdjustmented}" headerText="Adjustmented Date"
                              filterBy="#{item.cpAdjustmented}" filterMatchMode="exact">                      
                        <p:cellEditor>
                            <f:facet name="output">         
                                <h:outputText value="#{item.cpAdjustmented}">
                                    <f:convertDateTime pattern="MM/dd/yyyy" />
                                </h:outputText>
                            </f:facet>
                            <f:facet name="input">                              
                                <p:calendar id="cpAdjustmented" navigator="true" effect="explode"
                                            pattern="MM/dd/yyyy " 
                                            value="#{item.cpAdjustmented}" >
                                    <f:convertDateTime pattern="MM/dd/yyyy" />
                                </p:calendar>

                            </f:facet>
                        </p:cellEditor>
                    </p:column>
                    <p:column headerText="Status" sortBy="#{item.cpStatus}">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.cpStatus}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:selectBooleanCheckbox value="#{item.cpStatus}" />
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>   

                    <p:column>
                        <p:rowEditor/>
                    </p:column>
                </p:dataTable>
            </h:form>
        </ui:define>
    </ui:composition>
</html>

